var status = -1;
var selectionLog = [];
var items = [1182194, 2049134, 2049133, 2049132, 2049131, 2049130, 2049129, 2049124, 2049119, 2049118, 2049117, 2049116, 2049156, 2049155, 2049169, 2049168];

function start() {
    action(1, 0, 0)
}

function action(d, c, b) {
    if (im.getServerName().equals("BMS单机") && im.getServerName().equals("BMS至尊体验服") && !im.getServerName().equals("BMS至尊")) {
        im.playerMessage(1, " 使用环境异常，请还原服务端配置。");
        im.dispose();
        return
    }
    if (status == 0 && d == 0) {
        im.dispose();
        return
    }(d == 1) ? status++ : status--;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        im.dispose()
    } else {
        if (status === a++) {
            im.dispose();
            var e = im.getItemId();
            im.gainItem(e, -1);
            im.gainItem(items[im.rand(0, items.length)], 1);
            im.gainItem(4310020, im.rand(5, 30))
        }
    }
};